﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using LuaInterface;

public class LuaRigidTrigger : MonoBehaviour
{

    LuaTable table;
    LuaFunction func;
    void Start()
    {

    }

    public void AddHandler(LuaFunction luafunc)
    {
        func = luafunc;
    }

    public void AddHandler(LuaFunction luafunc, LuaTable luatable)
    {
        func = luafunc;
        table = luatable;
    }

    private void OnTriggerEnter2D(Collider2D collider)
    {
        if (func != null)
        {
            if (table != null)
            {
                func.Call(table, collider);
            }
            else
            {
                func.Call(collider);
            }
        }
    }
}
